/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package trunk.view.MenuClicDroit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;

/**
 *
 * @author Bu2spencer
 */
public class MenuClicDroitView extends JPopupMenu{
    
    protected JMenuItem select;
    protected JMenuItem deselect;
    protected JMenuItem symetrieO;
    protected JMenuItem symetrieX;
    protected JMenuItem symetrieY;
    protected JMenuItem clone;
    protected JMenuItem group;
    protected JMenuItem degroup;
    protected JMenuItem delete;
    
    public MenuClicDroitView() {
        
        select = new JMenuItem("Sélectionner Tout" );
        deselect = new JMenuItem("Délectionner Tout" );
        symetrieO = new JMenuItem("Symetrie Origine" );
        symetrieX = new JMenuItem("Symetrie Par X" );
        symetrieY = new JMenuItem("Symetrie Par Y" );
        clone = new JMenuItem("Cloner" );
        group = new JMenuItem("Grouper" );
        degroup = new JMenuItem("Dégrouper");
        delete = new JMenuItem("Supprimer");
        
            
        
            this.add(select);            
            this.add(deselect);
            this.add(new JSeparator());
            this.add(symetrieO);
            this.add(symetrieX);
            this.add(symetrieY);
            this.add(clone);
            this.add(new JSeparator());
            this.add(group);
            this.add(degroup);
            this.add(new JSeparator());
            this.add(delete);
            
        
        
    }
    
    public void setMenuClicDroitCtrl(MenuClicDroitCtrl ctrl){
        select.addActionListener(ctrl);
        deselect.addActionListener(ctrl);
        symetrieO.addActionListener(ctrl);
        symetrieX.addActionListener(ctrl);
        symetrieY.addActionListener(ctrl);
        clone.addActionListener(ctrl);
        group.addActionListener(ctrl);
        degroup.addActionListener(ctrl);
        delete.addActionListener(ctrl);
        
    }
    
    public class MenuClicDroitCtrl implements ActionListener{
    
    private MenuClicDroit view;
    
    public MenuClicDroitCtrl(MenuClicDroit view){
        this.view = view;
    }

        @Override
        public void actionPerformed(ActionEvent ae) {
            if(ae.getSource()==select)
                view.getPaintModel().selectAll();
            else if(ae.getSource()==deselect)    
                view.getPaintModel().resetSelection();
            else if(ae.getSource()==symetrieO)
                view.getPaintModel().symetrieO();
            else if(ae.getSource()==symetrieX)
                view.getPaintModel().symetrieX();
            else if(ae.getSource()==symetrieY)
                view.getPaintModel().symetrieY();
            else if(ae.getSource()==clone)
                view.getPaintModel().cloneElement();
            else if(ae.getSource()==group)
                view.getPaintModel().group();
            else if(ae.getSource()==degroup)
                view.getPaintModel().deGroup();
            else if(ae.getSource()==delete)
                view.getPaintModel().delete();
        }
    
}
}
